package main

import (
	"fmt"
)

func init() {
	//here := "eee"
}

type person struct {
	Name string
	age  int
}
type man struct {
	person
	alias   int
	Contact struct {
		Phone, City string
	}
}

func (p person) Eat(b int, c string) {
	fmt.Println(b, c)
	p.age = 333
	fmt.Println(p)
}
func main() {
	a := person{Name: "luxiaofei", age: 3}
	a.Name = "fefef"
	fmt.Println(a)
	b := person{"luxiaofei", 4}
	b.Eat(3, "ok")
	fmt.Println(b)
	m := man{}
	m.age = 34
	//
	m.Name = "man"
	m.Eat(56, "hehe")
	m.alias = 1

	//结构嵌套
	m.Contact.Phone = "15121045009"
	m.Contact.City = "上海"
	fmt.Println(m)
	fmt.Println(m.age)
	fmt.Println("--------------------")
	p := man{alias: 3, person: person{Name: "ok"}}
	fmt.Println(p)
	//匿名结构
	n := struct {
		Name string
		Age  int
	}{
		Name: "luxiaofei",
		Age:  23,
	}
	fmt.Println(n)

}
